package com.situ.vivamarket.model;

import com.situ.vivamarket.util.AdmAddGroup;
import com.situ.vivamarket.util.AdmEditGroup;
import com.situ.vivamarket.util.MemAddGroup;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

//管理员
@Setter
@Getter
@ToString
public class Admin {
    private Integer id;
    private String avatarUrl;//头像路径
    @NotEmpty(message = "管理名不可为空", groups = {AdmAddGroup.class})
    @Length(min = 3, max = 20, message = "账号长度必须介于3~20", groups = {AdmAddGroup.class})
    private String username;
    @NotEmpty(message = "管理员密码不可为空", groups = {AdmAddGroup.class})
    private String password;
    @NotEmpty(message = "管理员电话不可为空", groups = {AdmEditGroup.class,AdmAddGroup.class})
    private String phone;
    private Boolean enabled;
    private Boolean locked;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 指定日期时间格式
    private LocalDateTime userExpireTime;  //账号过期时间

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 指定日期时间格式
    private LocalDateTime credExpireTime;  //权限过期时间
    private Integer loginTimes;  //登录次数
    private LocalDateTime lastLoginTime; //上次登录时间
    private String lastLoginIp;  //上次登录IP
    private String description;
    private LocalDateTime createdTime;
    private String createdBy;
    private LocalDateTime updatedTime;
    private String updatedBy;
}
